package com.zhou.juc.test02_synchronized;

/**
 * @author zhouyanxiang
 * @create 2020-06-2020/6/20-9:20
 */
public class T3  {

    public synchronized void m1(){
        System.out.println(Thread.currentThread().getName() + " m1 start ...");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " m1 end ... ");
    }

    public void m2(){
        System.out.println(Thread.currentThread().getName() + " m2 start ...");
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " m2 end ....");
    }

    public static void main(String[] args) {
        T3 t3 = new T3();
        new Thread(t3::m1,"---- m1 ----").start();
        new Thread(t3::m2,"---- m2 ----").start();
    }
}
